//
//  FeedbackViewController.m
//  InviteJob
//
//  Created by LangLang on 17/10/26.
//  Copyright © 2017年 Shui. All rights reserved.
//

#import "FeedbackViewController.h"

@interface FeedbackViewController ()<UITextViewDelegate>


@property (weak, nonatomic) IBOutlet UIView *viewText;

@property (nonatomic,strong) SZTextView *textView;

@end

@implementation FeedbackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    TitleView(@"反馈意见")
    
    _textView = [[SZTextView alloc] init];
    _textView.placeholder = @"请输入反馈意见";
    _textView.backgroundColor = strColor(@"f6f6f6");
    _textView.font = [UIFont systemFontOfSize:15];
    _textView.delegate = self;
    [_viewText addSubview:_textView];
    [_textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@20);
        make.left.equalTo(@15);
        make.right.bottom.equalTo(@-15);
    }];
}

- (void)textViewDidChange:(SZTextView *)textField
{
    if (textField == self.textView) {
        if (textField.text.length > 150) {
            textField.text = [textField.text substringToIndex:150];
        }
    }
}

- (IBAction)submit:(id)sender {
    
    
    if (_textView.text.length == 0) {
        SHuiMBhudTextTimeStr(@"请输入反馈意见");
        return;
    }
    NSString *strUrl = [NSString stringWithFormat:post_serviceIn_api];
    isUser
    NSDictionary *parameter = @{@"user_id":user.user_id,
                                @"token":user.token,
                                @"content":_textView.text};
    
    [MBProgressHUD showMessag:@"提交中..." withDelay:0 toView:self. view withMode:MBProgressHUDModeIndeterminate hideWithDelay:0];
    [PostNetWorking postNetWorkingStr:strUrl andparameters:parameter Success:^(id responseObject) {
        NSLog(@"%@",responseObject);
        
        if ([responseObject[@"code"] intValue] == 200) {
            
            SHuiMBHidleYes
            SHuiMBhudTextTimeStr(@"反馈成功");
            
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                
                _textView.text = @"";
                
            });
            
            
        }else{
            SHuiMBHidleYes
            SHuiMBhudTextTimeStr(responseObject[@"mark"]);
        }
        
        
    } failed:^(NSError *error) {
        SHuiMBHidleYes
        SHuiMBhudTextTimeStr(@"网络错误");
    }];
    
}


@end
